ARG NODE_VERSION=18.14.2

FROM node:${NODE_VERSION}-slim as base

ARG PORT=3000

EXPOSE $PORT

ENV NODE_ENV=production

WORKDIR /app/frontend

# Build
FROM base as build

COPY --link package.json package-lock.json .
RUN npm install --production=false

COPY --link . .

RUN npm run build
RUN npm prune

# Run
FROM base

ENV PORT=$PORT

COPY --from=build /app/frontend/.output /app/frontend/.output


CMD [ "node", "/app/frontend/.output/server/index.mjs" ]